﻿using System.Linq;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace NazTek.Documenter.Ssis.Control.Tasks.PipeSubComponent
{
    internal sealed class Lookup : Base
    {
        internal Lookup(SsisPipe parent, IDTSComponentMetaData100 subComponent)
            : base(subComponent, parent)
        {
        }

        protected override Operation GetOperation(SsisPipe parent)
        {
            return new Operation
            {
                ConnectionName = parent.Parent.Connections.GetName(
                    Metadata.RuntimeConnectionCollection.OfType<IDTSRuntimeConnection100>().First().ConnectionManagerID),
                Statement = string.Format(
                    "{0}", Metadata.CustomPropertyCollection["SqlCommand"].Value.ToString().Replace("\n", "<br>"))
            };
        }
    }
}